<template>
	<myView>
		<u-form :model="model" ref="form">
			<slot></slot>
			<slot name="confirm">
				<myBottomBtn title="保存" @confirm="confirm"></myBottomBtn>
			</slot>
		</u-form>
	</myView>
</template>

<script>
	export default {
		name:"myForm",
		props: {
			model: {
				type: Object,
				default() {
					return {}
				}
			},
			rules: {
				type: Object,
				default () {
					return {}
				}
			},
		},
		data() {
			return {
				
			};
		},
		watch: {
			rules:{
				immediate: true,
				deep: true,
				handler(val) {
				this.$nextTick(()=>{
					this.$refs.form.setRules(val);
				})
				}
			}
		},
		methods: {
			async confirm(){
				let valid=await this.$refs.form.validate();
				if (valid){
					this.$emit('confirm');
				}
			}
		}
	}
</script>

<style lang="scss">
/deep/ .u-form-item__message{
	padding: 0 !important;
}
</style>